package frontend.parser.syntaxtree;

import frontend.lexer.TKType;
import frontend.parser.syntaxtree.symbol.NonTerminalSymbol;
import frontend.parser.syntaxtree.symbol.TerminalSymbol;

import java.util.function.Consumer;

public class StmtNodeForReturn extends StmtNode {
    public ExpNode exp;
    public int returnLineNum = -1;

    @Override
    public void walk(Consumer<TerminalSymbol> terConsumer, Consumer<NonTerminalSymbol> nonTerConsumer) {
        terConsumer.accept(new TerminalSymbol(TKType.RETURNTK));

        if (exp != null) {//有无exp
            exp.walk(terConsumer, nonTerConsumer);
        }

        terConsumer.accept(new TerminalSymbol(TKType.SEMICN));

        nonTerConsumer.accept(new NonTerminalSymbol(this));
    }
}
